<div bsModal #actionModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="actionModal"
  aria-hidden="true" [config]="{ backdrop: 'static' }">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">{{ title }}管理</h4>
        <button type="button" class="close" (click)="close()" [attr.aria-label]="l('Close')">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <div class="modal-body">
        <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
          <tabset #tset class="tab-container tabbable-line">
            <tab  customClass="m-tabs__item">
              <span *tabHeading>
                批量管理 &nbsp;<span class='m-badge m-badge--danger'>
                  {{carTechRules.length}}
                </span>
              </span>
              <form class="horizontal-form" autocomplete="off">
                <div class="m-form m-form--label-align-right">
                  <div class="row align-items-center m--margin-bottom-10">
                    <div class="col-xl-12">
                      <div class="form-group m-form__group align-items-center">
                        <div class="input-group">
                          <input [(ngModel)]="scanFilterText" name="scanFilterText" class="form-control m-input"
                            [placeholder]="l('SearchWithThreeDot')" type="text" />
                          <span class="input-group-btn">
                            <button (click)="scaninit()" class="btn btn-primary" type="submit">
                              <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                            </button>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </form>
              <p-table #carDataTable [value]="carTechRules" [(selection)]="selectCarTechRules" [paginator]="false"
                [lazy]="false" [scrollable]="true" ScrollWidth="100%" rows="1000"
                [responsive]="primengTableHelper.isResponsive" [resizableColumns]="primengTableHelper.resizableColumns"
                [globalFilterFields]="[]">
                <ng-template pTemplate="header">
                  <tr>
                    <th style="width: 50px">
                      <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                    </th>
                    <th  style="width: 150px" pSortableColumn="TechRuleInfo.FileCode">
                      编号
                      <p-sortIcon field="TechRuleInfo.FileCode"></p-sortIcon>
                    </th>
                    <th pSortableColumn="TechRuleInfo.ModelName">
                      型号
                      <p-sortIcon field="TechRuleInfo.ModelName"></p-sortIcon>
                    </th>
                    <th pSortableColumn="TechRuleInfo.ModelName">
                      图号
                      <p-sortIcon field="TechRuleInfo.ModelName"></p-sortIcon>
                    </th>
                    <th>
                      是否重复
                    </th>
                    <th>
                      日志
                    </th>
                    <th pSortableColumn="PositionId">
                      位置
                      <p-sortIcon field="PositionId"></p-sortIcon>
                    </th>
                  </tr>
                </ng-template>
                <ng-template pTemplate="body" let-record="$implicit">
                  <tr>
                    <td style="width: 50px">
                      <p-tableCheckbox [value]="record"></p-tableCheckbox>
                    </td>
                    <td style="width: 150px"><span class="ui-column-title"> 编号</span>
                      {{ record.techRuleInfo.fileCode }}</td>
                    <td><span class="ui-column-title"> 型号</span>
                      {{ record.techRuleInfo.modelName }}</td>
                    <td><span class="ui-column-title"> 图号</span>
                      {{ record.techRuleInfo.drawingCode }}</td>
                    <td><span class="ui-column-title"> 是否重复</span>
                      <button *ngIf="record.hasSameFile=='有'" type="button" class="btn btn-warning btn-sm"
                        style="font-size: .875rem !important;" (click)="TechRuleSameModal.show(record)">
                        {{ record.hasSameFile }}
                      </button>
                      <span *ngIf="record.hasSameFile=='无'"> 无</span></td>
                    <td><span class="ui-column-title">日志</span>
                      <button type="button" class="btn btn-warning btn-sm" style="font-size: .875rem !important;"
                        (click)="TechRuleLogModal.show(record)">
                        日志
                      </button></td>
                    <td><span class="ui-column-title"> 位置</span> {{ record.positionName }}</td>
                  </tr>
                </ng-template>
              </p-table>
              <div style="margin-top: 40px;"></div>
              <div class="row" [hidden]="type!=1">
                <div class="col-md-4">
                  <div class="form-group">
                    <select #areaCombobox name="area" class="form-control" [(ngModel)]="areaId"
                      [attr.data-live-search]="true" jq-plugin="selectpicker" (change)="loadShelfs()" title="选择库房">
                      <option *ngFor="let area of areas" [value]="area.id">{{area.name}}</option>
                    </select>
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <select #shelfCombobox name="shelf" class="form-control" [(ngModel)]="shelfId"
                      [attr.data-live-search]="true" (change)="loadPositions()" title="选择档案柜">
                      <option *ngFor="let shelf of shelfs" [value]="shelf.id">{{shelf.name}}</option>
                    </select>
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <select #positionCombobox name="position" class="form-control" [(ngModel)]="positionId"
                      jq-plugin="selectpicker" [attr.data-live-search]="true" title="选择架位">
                      <option *ngFor="let position of positions" [value]="position.id">{{position.name}}</option>
                    </select>
                  </div>
                </div>
              </div>
              <!-- <div class="row">
                <div class="col-6">
                  <div class="form-group">
                    <label for="StockInfo">{{ title }}信息</label>
                    <input id="StockInfo" type="text" name="StockInfo" class="form-control" [(ngModel)]="StockInfo" />
                  </div>
                </div>
                <div class="col-6">
                  <div class="form-group">
                    <label for="Remark">{{ title }}备注</label>
                    <input id="Remark" type="text" name="Remark" class="form-control" [(ngModel)]="Remark" />
                  </div>
                </div>
              </div> -->

              <div style="text-align: right;">
                <!-- <button type="button" class="btn btn-success" (click)="createOrEditTechRuleModal.show('',type)"
                  [buttonBusy]="saving" *ngIf="type!=5">
                  <i class="fa fa-plus"></i> 扫码测试
                </button> -->
                <button type="button" class="btn btn-warning" (click)="cancelStocks()" [buttonBusy]="saving">
                  <i class="fa fa-minus"></i> 从车中取消
                </button>
                <button type="button" (click)="saveStocks()" class="btn btn-primary" [buttonBusy]="saving"
                  *ngIf="type==2" [busyText]="title + '中...'" [disabled]="!selectCarTechRules.length">
                  <i class="fa fa-save"></i> <span>借阅</span>
                </button>
                <button type="button" (click)="saveStocks()" class="btn btn-primary" [buttonBusy]="saving"
                  *ngIf="type==3" [busyText]="title + '中...'" [disabled]="!selectCarTechRules.length">
                  <i class="fa fa-save"></i> <span>归还</span>
                </button>
                <button type="button" (click)="saveStocks()" class="btn btn-primary" [buttonBusy]="saving"
                  *ngIf="type==1" [busyText]="title + '中...'"
                  [disabled]="!selectCarTechRules.length || (type==1&&!positionId)">
                  <i class="fa fa-save"></i> <span>入库</span>
                </button>
                <button type="button" (click)="saveStocks()" class="btn btn-primary" [buttonBusy]="saving"
                  *ngIf="type==4" [busyText]="title + '中...'" [disabled]="!selectCarTechRules.length">
                  <i class="fa fa-save"></i> <span>报废</span>
                </button>
                <button type="button" (click)="saveStocks()" class="btn btn-primary" [buttonBusy]="saving"
                  *ngIf="type==5" [busyText]="title + '中...'" [disabled]="!selectCarTechRules.length">
                  <i class="fa fa-save"></i> <span>追回</span>
                </button>
              </div>
            </tab>
            <tab heading="日志管理" customClass="m-tabs__item">
              <form class="horizontal-form" autocomplete="off">
                <div class="m-form m-form--label-align-right">
                  <div class="row align-items-center m--margin-bottom-10">
                    <div class="col-xl-12">
                      <div class="form-group m-form__group align-items-center">
                        <div class="input-group">
                          <input [(ngModel)]="logFilterText" name="logFilterText" class="form-control m-input"
                            [placeholder]="l('SearchWithThreeDot')" type="text" />
                          <span class="input-group-btn">
                            <button (click)="getTechRuleLogs()" class="btn btn-primary" >
                              <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                            </button>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </form>
              <p-table #logDataTable (onLazyLoad)="getTechRuleLogs($event)" [value]="primengTableHelper.records"
                rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
                [resizableColumns]="primengTableHelper.resizableColumns">
                <ng-template pTemplate="header">
                  <tr>
                    <th  style="width: 150px">编号</th>
                    <th>图号</th>
                    <th>操作人</th>
                    <th>操作时间</th>
                    <th>操作类型</th>
                    <th>出库时间</th>
                    <th>入库时间</th>
                  </tr>
                </ng-template>
                <ng-template pTemplate="body" let-record="$implicit">
                  <tr>
                    <td  style="width: 150px">{{ record.fileCode}}</td>
                    <td>{{ record.drawingCode}}</td>
                    <td>{{ record.operUserName}}</td>
                    <td>{{ record.creationTime | momentFormat:'YYYY-MM-DD HH:mm'}} </td>
                    <td>
                      <span *ngIf="record.operationName  == '借阅'" class="m-badge m-badge--primary m-badge--wide">
                        {{ record.operationName }}</span>
                      <span *ngIf="record.operationName  == '归还'" class="m-badge m-badge--success m-badge--wide">
                        {{ record.operationName }}</span>
                      <span *ngIf="record.operationName  == '入库'" class="m-badge m-badge--warning m-badge--wide">
                        {{ record.operationName }}</span>
                      <span *ngIf="record.operationName  == '报废'" class="m-badge m-badge--danger m-badge--wide">
                        {{ record.operationName }}</span>
                      <span *ngIf="record.operationName  == '追回'" class="m-badge m-badge--info m-badge--wide">
                        {{ record.operationName }}</span>
                    </td>
                    <td>{{ record.outDate | momentFormat:'YYYY-MM-DD HH:mm'}} </td>
                    <td>{{ record.backDate | momentFormat:'YYYY-MM-DD HH:mm'}} </td>
                  </tr>
                </ng-template>
              </p-table>
              <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">{{ l('NoData') }}</div>
              <div class="primeng-paging-container">
                <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #logPaginator
                  (onPageChange)="getTechRuleLogs($event)" [totalRecords]="primengTableHelper.totalRecordsCount"
                  [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                </p-paginator>
                <span class="total-records-count"> 共计：{{ primengTableHelper.totalRecordsCount }} </span>
              </div>
            </tab>
            <tab *ngIf="type==2" customClass="m-tabs__item">
              <span *tabHeading>
                已借出文件 &nbsp;<span class='m-badge m-badge--danger'>
                  {{primengTableHelper1.totalRecordsCount}}
                </span>
              </span>
              <form class="horizontal-form" autocomplete="off">
                <div class="m-form m-form--label-align-right">
                  <div class="row align-items-center m--margin-bottom-10">
                    <div class="col-xl-12">
                      <div class="form-group m-form__group align-items-center">
                        <div class="input-group">
                          <input [(ngModel)]="FilterText" name="FilterText" class="form-control m-input"
                            [placeholder]="l('SearchWithThreeDot')" type="text" />
                          <span class="input-group-btn">
                            <button (click)="getOutTechRules()" class="btn btn-primary" >
                              <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                            </button>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </form>
              <p-table #outDataTable (onLazyLoad)="getOutTechRules($event)" [value]="primengTableHelper1.records"
                rows="{{primengTableHelper1.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper1.isResponsive"
                [resizableColumns]="primengTableHelper1.resizableColumns">
                <ng-template pTemplate="header">
                  <tr>
                    <th pSortableColumn="TechRuleInfo.FileCode">
                      状态
                      <p-sortIcon field="TechRuleInfo.FileCode"></p-sortIcon>
                    </th>
                    <th style="width: 150px" pSortableColumn="TechRuleInfo.FileCode">
                      编号
                      <p-sortIcon field="TechRuleInfo.FileCode"></p-sortIcon>
                    </th>
                    <th pSortableColumn="TechRuleInfo.ModelName">
                      型号
                      <p-sortIcon field="TechRuleInfo.ModelName"></p-sortIcon>
                    </th>
                    <th pSortableColumn="TechRuleInfo.ModelName">
                      图号
                      <p-sortIcon field="TechRuleInfo.ModelName"></p-sortIcon>
                    </th>
                    <th>
                        借阅人
                      </th>
                    <th>
                      日志
                    </th>
                  </tr>
                </ng-template>
                <ng-template pTemplate="body" let-record="$implicit">
                  <tr>
                    <td>
                      <span class="m-badge m-badge--danger">{{ record.statusName }}</span>
                    </td>
                    <td style="width: 150px"><span class="ui-column-title"> 编号</span>
                      {{ record.techRuleInfo.fileCode }}</td>
                    <td><span class="ui-column-title"> 型号</span>
                      {{ record.techRuleInfo.modelName }}</td>
                    <td><span class="ui-column-title"> 图号</span>
                      {{ record.techRuleInfo.drawingCode }}</td>
                      <td><span class="ui-column-title"> 借阅人</span>
                        {{ record.currentUserName }}</td>
                    <td><span class="ui-column-title">日志</span>
                      <button type="button" class="btn btn-warning btn-sm" style="font-size: .875rem !important;"
                        (click)="TechRuleLogModal.show(record)">
                        日志
                      </button></td>
                  </tr>
                </ng-template>
              </p-table>
              <div class="primeng-no-data" *ngIf="primengTableHelper1.totalRecordsCount == 0">{{ l('NoData') }}</div>
              <div class="primeng-paging-container">
                <p-paginator [rows]="primengTableHelper1.defaultRecordsCountPerPage" #outPaginator
                  (onPageChange)="getOutTechRules($event)" [totalRecords]="primengTableHelper1.totalRecordsCount"
                  [rowsPerPageOptions]="primengTableHelper1.predefinedRecordsCountPerPage">
                </p-paginator>
                <span class="total-records-count"> 共计：{{ primengTableHelper1.totalRecordsCount }} </span>
              </div>
            </tab>
          </tabset>
        </div>
      </div>
    </div>
  </div>
  <TechRuleSameModal #TechRuleSameModal (modalSave)="getCarTechRules()"></TechRuleSameModal>
  <TechRuleLogModal #TechRuleLogModal></TechRuleLogModal>
  <createOrEditTechRuleModal #createOrEditTechRuleModal (modalSave)="getCarTechRules()"></createOrEditTechRuleModal>
</div>
